<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Access {
	protected $CI;
	protected $user_model;
	
	function __construct() {
		$this->CI =& get_instance();
		$this->CI->load->model('user_model');
		$this->user_model =& $this->CI->user_model;
	}
	
	function login($user,$pwd){
		$login_result = $this->user_model->check_login($user,$pwd);
		if($login_result){
			$user_data = array(
				'user'=>$login_result['id'],
				'role_id'=>$login_result['role_id'],
                                'nama_user'=>$login_result['nama']
			);
			$this->CI->session->set_userdata($user_data);
			return TRUE;
		}else{
			return FALSE;
		}
	}
	
	function is_login(){
            
		return ($this->CI->session->userdata('user')
				&& $this->CI->session->userdata('role_id'));
	}
	
	function logout(){
		$this->CI->session->unset_userdata('nim');
		$this->CI->session->unset_userdata('nama');
		$this->CI->session->unset_userdata('nilai_tes');
		$this->CI->session->unset_userdata('role');
	}
}
/** End of file */